import App from './App'
// import store from './store'
import uView from './uni_modules/vk-uview-ui';
import share from '@/utils/share'
import define from '@/utils/define'
import request from '@/utils/request'
import xf from '@/utils/index'
import resources from '@/libs/resource';
import emotion from '@/utils/common/emotion.js';
import * as enums from '@/utils/common/enums.js';
import * as date from '@/utils/common/date';
import * as socketApi from '@/utils/common/wssocket';
import * as messageType from '@/utils/common/messageType';
import * as pinia from 'pinia';
import useUserStore from '@/store/modules/user.js'
import useChatStore from '@/store/modules/chatStore.js'
import useFriendStore from '@/store/modules/friendStore.js'
import useConfigStore from '@/store/modules/configStore.js'
import useBaseStore from '@/store/modules/base.js'
// #ifdef H5
import * as recorder from '@/utils/common/recorder-h5';
// #endif
// #ifndef H5
import * as recorder from '@/utils/common/recorder-app';
// #endif
// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
Vue.config.productionTip = false
App.mpType = 'app'
// 添加实例属性
Object.assign(Vue.prototype, {
	define,
	request,
	xf,
	resources,
	// $store: store,
	$wsApi: socketApi,
	$msgType: messageType,
	$emo: emotion,
	$enums: enums,
	$date: date,
	$rc: recorder
})
Vue.use(uView)
Vue.mixin(share)
const app = new Vue({
	...App
})
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
export function createApp() {
	const app = createSSRApp(App)
	app.use(uView)
	app.mixin(share)
	app.use(pinia.createPinia());
	app.config.globalProperties.define = define
	app.config.globalProperties.request = request
	app.config.globalProperties.xf = xf;
	// app.config.globalProperties.$store=store;
	app.config.globalProperties.resources = resources;
	app.config.globalProperties.$wsApi = socketApi;
	app.config.globalProperties.$msgType = messageType;
	app.config.globalProperties.$emo = emotion;
	app.config.globalProperties.$enums = enums;
	app.config.globalProperties.$date = date;
	app.config.globalProperties.$rc = recorder;
	// 初始化时再挂载store对象
	app.config.globalProperties.$mountStore = () => {
		app.config.globalProperties.chatStore = useChatStore();
		app.config.globalProperties.friendStore = useFriendStore();
		app.config.globalProperties.configStore = useConfigStore();
		app.config.globalProperties.userStore = useUserStore();
		app.config.globalProperties.baseStore=useBaseStore();
	}
	return {
		app,
		pinia
	}
}
// #endif